﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GS.CMS.Entities;
using System.Data;

public partial class usercontrols_searchbox : System.Web.UI.UserControl
{
    DataTable dtRoot;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindCategory();
    }
    public DataTable dtCategoryRoot
    {
        set
        {
            dtRoot = value;
        }
    }
    private void BindCategory()
    {
        try
        {
            if (dtRoot != null)
            {
                DataView dv = dtRoot.DefaultView;
                dv.RowFilter = "ParentCategoryID Is Null OR ParentCategoryID =''";
                DataTable dtRootFilter = dv.ToTable();
                ddlCategory.DataSource = dtRootFilter;
                ddlCategory.DataValueField = "CategoryID";
                ddlCategory.DataTextField = "Name";
                ddlCategory.DataBind();
                ddlCategory.Items.Insert(0, new ListItem("All Category", "All"));
            }
        }
        catch (Exception ex)
        {
            TrackingError.AddTrackingError("usercontrols_searchbox - Function: BindCategory", ex.Message);
        }
    }
}